package com.example.administrator.testhttpclient;

import android.util.Log;
import android.view.View;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/11/24.
 */
public class CatchCourse {
    public String  getTable() throws  Exception{
                HttpClient client = new DefaultHttpClient();
                HttpPost post = new HttpPost("http://121.248.70.214/jwweb/ZNPK/TeacherKBFB_rpt.aspx");
                post.addHeader("Cookie",MainActivity.reinf.getCookie());
                post.addHeader( "Referer","http://121.248.70.214/jwweb/ZNPK/TeacherKBFB.aspx");
                List<NameValuePair> pairs = new ArrayList<NameValuePair>();
                NameValuePair p1 = new BasicNameValuePair("Sel_XNXQ",MainActivity.reinf.getSel_XNXQ());
                NameValuePair p2 = new BasicNameValuePair("Sel_JS","0003043");
                NameValuePair p3 = new BasicNameValuePair("type","1");
                String s = MainActivity.checkText.getText().toString();
                NameValuePair p4 = new BasicNameValuePair("txt_yzm",s);
                pairs.add(p1);
                pairs.add(p2);
                pairs.add(p3);
                pairs.add(p4);
                String ss = null;
                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs);
                post.setEntity(entity);
                HttpResponse response=client.execute(post);
                HttpEntity entity2 = response.getEntity();
                ss = EntityUtils.toString(entity2);
                Log.i("tiantong",ss+"....");
        return ss;
    }
}
